package com.code.petapp.util

import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat

class VersionUtils {
    companion object {
        const val TAG = "VersionUtils"
        private val permissionListL = arrayOf(
            Manifest.permission.READ_EXTERNAL_STORAGE,
//            Manifest.permission.WRITE_EXTERNAL_STORAGE,
//            Manifest.permission.CAMERA,
//            Manifest.permission.RECORD_AUDIO
        )
        private val permissionListH = arrayOf(
            Manifest.permission.READ_MEDIA_IMAGES,
//            Manifest.permission.READ_MEDIA_VIDEO,
//            Manifest.permission.CAMERA,
//            Manifest.permission.RECORD_AUDIO
        )

        fun getPermission(): Array<String> {
            val version = Build.VERSION.SDK_INT
            return if (version >= Build.VERSION_CODES.TIRAMISU) {
                permissionListH
            } else {
                permissionListL
            }
        }

        fun checkPermissionAllGranted(permissions: Array<String>, activity: Activity): Boolean {
            for (permission in permissions) {
                if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
                    return false
            }}
            return true
        }}
}